package com.example.shirodemo2.shiro.realm;

import com.demo.bean.User;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authc.*;
import org.apache.shiro.authz.AuthorizationInfo;
import org.apache.shiro.realm.AuthorizingRealm;
import org.apache.shiro.subject.PrincipalCollection;

/**
 * Created on 2018/10/8
 *
 * @author Saligia
 */
@Slf4j
public class SsoRealm extends AuthorizingRealm {

    @Override
    @SuppressWarnings("unchecked")
    protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) {
        return null;
    }

    @Override
    protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken authenticationToken) throws AuthenticationException {
        UsernamePasswordToken token = (UsernamePasswordToken) authenticationToken;
        User user = new User("11111", "张三");
        return new SimpleAuthenticationInfo(user, user.getPassword(), getName());
    }
}
